<input type="hidden" value="{$list.id}" name="mwdisheid" id="mwdisheid"/>
<h4 class="color_main fjname1">{$list.title}</h4>
<form id="dishpert">
<input type="hidden" value="{$outletid}" name="outletid">
<input type="hidden" name="solevar" value="{:create_id()}" />
<input type="hidden" name="id"      value="{$list.id}"     />
<eq name="list.tprice" value="0.00" >
	<input type="hidden" name="mprice"  value="{$list.sprice}" />
	<input type="hidden" name="isspec"  value="2" />
<else />
	<input type="hidden" name="mprice"  value="{$list.tprice}" />
	<input type="hidden" name="isspec"  value="1" />
</eq>
<input type="hidden" name="model"   value="dishes"         />
<input type="hidden" name="isprop"  value="haveprop"       />
<table width="100%" border="0" cellpadding="0" cellspacing="0" id="table">
<volist name="list['gnfr']" id="vo" key="k" >
	
	<tr>
		<th colspan="2" id="pertentitle{$k}" rel="{$vo.entitle}">{$vo.title} <eq name="vo.ismust" value="1"><em class="color_main">* 必须选择</em></eq></th>		
	</tr>
	<tr>
		<eq name="vo.type" value="1">
			<input type="hidden" name="flag[{$k-1}][entitle]" value="{$vo.entitle}" />
			<input type="hidden" name="flag[{$k-1}][title]"   value="{$vo.title}" />
			<input type="hidden" name="flag[{$k-1}][xtype]"   value="{$vo.type}" />
			<td>
				<volist name="vo['config']" id="con" key="l">
					<div class="kx kx1 selectRadio{$k}" entitle="{$con.entitle}" title="{$con.title}" num="{$con.dnum}" price="{$con.mprice}" psprice="{$con.psprice}" key="{$k}" keys="{$l}">
						<eq name="vo.ismust" value="1">
							<input name="kexuan{$k}" type="radio" checked />
						<else />
							<input type="radio" name="kexuan{$k}" />
						</eq>
						{$con.title}<notempty name="con.mprice" >( 加 ￥{$con.mprice})</notempty>
						<input type="hidden"   name="flag[{$k-1}][config][{$l-1}][title]"   id="ktitle{$k}{$l}"   />
						<input type="hidden"   name="flag[{$k-1}][config][{$l-1}][entitle]" id="kentitle{$k}{$l}" />
						<input type="hidden"   name="flag[{$k-1}][config][{$l-1}][mprice]"  id="kprice{$k}{$l}"   />
						<input type="hidden"   name="flag[{$k-1}][config][{$l-1}][psprice]" id="kpsprice{$k}{$l}"   />
						<input type="hidden"   name="flag[{$k-1}][config][{$l-1}][num]"     id="knum{$k}{$l}"     />
					</div>
				</volist>
				
			</td>
		</eq>
 		<eq name="vo.type" value="2">
			<input type="hidden" name="flag[{$k-1}][entitle]"  value="{$vo.entitle}" />
			<input type="hidden" name="flag[{$k-1}][title]"    value="{$vo.title}"   />
			<input type="hidden" name="flag[{$k-1}][xtype]"    value="{$vo.type}"    />
			<td>
				<volist name="vo['config']" id="con" key="m">
					<div class="kx kx2" entitle="{$con.entitle}" title="{$con.title}" price="{$con.mprice}" psprice="{$con.psprice}" rel="check"  key="{$k}" keys="{$m}">
						<input type="checkbox" name="check{$k-1}[]" class="check" fenshu='ok' />
						{$con.title}<notempty name="con.mprice" >( 加 ￥{$con.mprice})</notempty>
						<input type="hidden"   name="flag[{$k-1}][config][{$m-1}][title]"   id="ctitle{$k}{$m}"   />
						<input type="hidden"   name="flag[{$k-1}][config][{$m-1}][entitle]" id="centitle{$k}{$m}" />
						<input type="hidden"   name="flag[{$k-1}][config][{$m-1}][num]"     id="cnum{$k}{$m}"     />
						<input type="hidden"   name="flag[{$k-1}][config][{$m-1}][mprice]"  id="cprice{$k}{$m}"   />
						<input type="hidden"   name="flag[{$k-1}][config][{$m-1}][psprice]" id="cpsprice{$k}{$m}"   />
						 
						<select name="check_{$k}_num" id="xz{$k}{$m}" class="check_select">
							<for start="1" end="$con.maxnum" >
								<option value="{$i}">{$i}</option>
							</for>
						</select>
					</div>
				</volist>
			</td>
		</eq>
	</tr>
</volist>
	<tr style="height:80px;">
		<td colspan="2" align="center">
			<span class="tanchuprice yuanprice">
				<eq name="list.tprice" value="0.00" >
					{$list.sprice}
				<else/>
					{$list.tprice}
				</eq>
			</span>
			<span class="tanchuprice">+</span>
			<span class="tanchuprice xianprice"></span>
			<span class="tanchuprice">=￥</span>
			<span class="tanchuprice total">{$list.sprice}</span>
		</td>
	</tr>
	<tr>
		<td colspan="2" align="center"><div class="fixed"><a class="qxbtn" rel="c1">取消</a><a rel="c2" class="scbtn">加入购物车</a></div></td>
	</tr>
</table>
</form>
<script type="text/javascript">

$(function(){
	
	getprice();
	//复选框选中时，出现下拉列表
	$('.check').click(function(){
		if($(this).attr('checked')){
			$(this).siblings('.check_select').show();	
		}else{
			$(this).siblings('.check_select').hide();	
		}
	});

	$(".kx1").each(function(i){
		var key      = $(this).attr("key");
		var keys     = $(this).attr("keys");
		var title    = $(this).attr("title");
		var entitle  = $(this).attr("entitle");
		var num      = $(this).attr("num");
		var price    = $(this).attr("price");
		var psprice  = $(this).attr("psprice");
		var obj = $(this).children("input[type=radio]").attr("checked");
		if(obj){
			$("#ktitle"+key+keys).val(title);
			$("#kentitle"+key+keys).val(entitle);
			$("#knum"+key+keys).val(num);
			$("#kprice"+key+keys).val(price);
			$("#kpsprice"+key+keys).val(psprice);
			getprice();
		}
		$(this).children("input[type=radio]").on("click",function(){
			$('.selectRadio'+key).each(function(){
				 $(this).children("input[type=hidden]").val("");
			 })
			if($(this).attr("checked")){
				$("#ktitle"+key+keys).val(title);
				$("#kentitle"+key+keys).val(entitle);
				$("#knum"+key+keys).val(num);
				$("#kprice"+key+keys).val(price);
				$("#kpsprice"+key+keys).val(psprice);
				getprice();
			}else{
				getprice();
			}
		});
	});
	
	$(".kx2").each(function(j){
		var title   = $(this).attr("title");
		var entitle = $(this).attr("entitle");
		var price   = $(this).attr("price");
		var psprice = $(this).attr("psprice");
		var key     = $(this).attr("key");
		var keys    = $(this).attr("keys");
		$(this).children("input[type=checkbox]").on("click",function(){
			if($(this).attr("checked")){
				$("#ctitle"+key+keys).val(title);
				$("#centitle"+key+keys).val(entitle);
				$("#cprice"+key+keys).val(price);
				$("#cpsprice"+key+keys).val(psprice);
				$("#cnum"+key+keys).val("1");
				$("#xz"+key+keys).live('change',function(h){
					$("#cnum"+key+keys).val($(this).val());
					getprice();
				});
				getprice();
			}else{
				$("#ctitle"+key+keys).val("");
				$("#centitle"+key+keys).val("");
				$("#cprice"+key+keys).val("");
				$("#cpsprice"+key+keys).val("");
				getprice();
			}
		});
	});
});

function getprice(){
	var totalprice = 0;
	$(".kx1").each(function(i){
		var price = $(this).attr("price");
		var obj   = $(this).children("input[type=radio]").attr("checked");
		if(obj){
			price = price?price:0;
			totalprice += parseInt(price);
		}
	});
	$(".kx2").each(function(j){
		var price = $(this).attr("price");
		var num   = $(this).children('select').val();
		var flag  = $(this).children("input[type=checkbox]").prop('checked');
		if(flag){
			num   = num?num:1;
			price = price?price:0;
			totalprice += num*parseInt(price);
		}
	});
	setprice(totalprice);
}

function setprice(totalprice){
	
	totalprice = totalprice?totalprice:0;
	
	var yuanprice = parseInt($('.yuanprice').html());
	var total     = yuanprice+totalprice;
	
	total      = total.toFixed(2);
	totalprice = totalprice.toFixed(2);
	$('.xianprice').html(totalprice);
	$('.total').html(total);
}
</script>
